// @ts-check

/** @type {import("stylelint").Config} */
export default {
    // 定义了继承的 Stylelint 配置，如标准配置
    extends: [
        "stylelint-config-standard",
        "stylelint-config-html/vue",
        "stylelint-config-recess-order",
    ],
    // 定义了使用的 Stylelint 插件，如 SCSS 插件
    plugins: ["stylelint-scss", "stylelint-order", "@stylistic/stylelint-plugin"],
    // 为不同类型的文件指定特定的 CSS 检查规则和语法解析器
    overrides: [
        {
            files: ["**/*.(css|html|vue)"],
            customSyntax: "postcss-html",
        },
        {
            files: ["*.scss", "**/*.scss"],
            customSyntax: "postcss-scss",
            extends: [
                "stylelint-config-standard-scss",
                "stylelint-config-recommended-vue/scss",
            ],
        },
    ],
    // 自定义的 Stylelint 规则
    rules: {
        "@stylistic/indentation": 4, // 设置缩进为 4 个空格
        "@stylistic/block-opening-brace-space-before": "always", // 样式名称后面需要加上一个空格
        "selector-class-pattern": null,
        "no-descending-specificity": null,
        "scss/dollar-variable-pattern": null,
        "scss/at-extend-no-missing-placeholder": null,
        "selector-pseudo-class-no-unknown": [
            true,
            {
                ignorePseudoClasses: ["deep", "global"],
            },
        ],
        "selector-pseudo-element-no-unknown": [
            true,
            {
                ignorePseudoElements: ["v-deep", "v-global", "v-slotted"],
            },
        ],
        "at-rule-no-unknown": [
            true,
            {
                ignoreAtRules: [
                    "tailwind",
                    "apply",
                    "variants",
                    "responsive",
                    "screen",
                    "function",
                    "if",
                    "each",
                    "include",
                    "mixin",
                    "use",
                    "extend",
                ],
            },
        ],
        "rule-empty-line-before": [
            "always",
            {
                ignore: ["after-comment", "first-nested"],
            },
        ],
        "unit-no-unknown": [true, { ignoreUnits: ["rpx"] }],
        "order/order": [
            [
                "dollar-variables",
                "custom-properties",
                "at-rules",
                "declarations",
                {
                    type: "at-rule",
                    name: "supports",
                },
                {
                    type: "at-rule",
                    name: "media",
                },
                "rules",
            ],
            { severity: "warning" },
        ],
    },
    ignoreFiles: ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx", "report.html", "stats.html"],
};
